/*
 *  Borum, Boolean rule manipulator.
 *  Copyright (C) 2009 Jon Lennersten, Johan Hedin, Daniel Rosenberg
 *
 *  This file is part of Borum.
 *
 *  Borum is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Borum is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Borum.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.mawell.borum;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;

import java.io.Serializable;
import java.util.HashMap;

@Root
public class Rule implements Serializable {

    @Element(required=false)
    String name = "";

    @Attribute(required=false)
    private boolean edited = false;
    
    @Attribute(required=false)
    private boolean newRule = false;

    @Attribute(required=false)
    private boolean deleted = false;

    @Attribute(required=false)
    private boolean locked = false;

    @Attribute(required=false)
    private boolean selected = false;

    @Element(required=false)
    OperandNode rootNode;

    @ElementMap(required=false, attribute=true, keyType = java.lang.String.class, valueType = java.lang.String.class)
    HashMap<String, String> properties;


    public Rule() {
        properties = new HashMap<String, String>();
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isEdited() {
        return edited;
    }

    public void setEdited(boolean edited) {
        this.edited = edited;
    }

    public boolean isNewRule() {
        return newRule;
    }

    public void setNewRule(boolean newRule) {
        this.newRule = newRule;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public boolean isLocked() {
        return locked;
    }

    public void setLocked(boolean locked) {
        this.locked = locked;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public OperandNode getRootNode() {
        return rootNode;
    }

    public void setRootNode(OperandNode rootNode) {
        this.rootNode = rootNode;
    }

    public HashMap<String, String> getProperties() {
        return properties;
    }

    public void setProperties(HashMap<String, String> properties) {
        this.properties = properties;
    }

    public String getProperty(String key) {
        return properties.get(key);
    }

    public String setProperty(String key, String value) {

        String oldValue = properties.get(key);
        properties.put(key, value);

        return oldValue;
    }
}
